package org.jeroen.banking;

import java.math.BigDecimal;

public class Account {
    private BigDecimal balance = new BigDecimal("0.00");

    public void withdraw(BigDecimal amount) {
        if (hasEnoughMoney(amount)) {
            balance = balance.subtract(amount);
            // TODO: Pass on money withdrawn event
        } else {
            // TODO: Pass on insuffucient fonds event
        }
    }

    private boolean hasEnoughMoney(BigDecimal required) {
        return balance.compareTo(required) >= 0;
    }

    public void deposit(BigDecimal amount) {
        balance = balance.add(amount);
        // TODO: Pass on money deposited event
    }
}
